money = 5000000
name = None
name = input("请输入您的姓名：")


# 定义查询余额函数
def query():
    print("----------------查询余额-----------------")
    print(f"{name},您好，您的余额剩余：{money}")


# 存款
def saving(num):
    global money
    money += num
    print("----------------存款-----------------")
    print(f"{name}，您好，您存款{num}成功。")
    print(f"{name}，您好，您的余额剩余{money}")


# 取款
def get_money(num):
    global money
    print("----------------取款-----------------")
    if money >= num:
        money -= num
        print(f"{name}，您好，您取款{num}成功。")
        print(f"{name}，您好，您的余额剩余{money}")
    else:
        print(f"{name}，您好，您余额不足。")
        print(f"{name}，您好，您的余额剩余{money}")


# 定义主菜单函数
def main():
    print("----------------主菜单-----------------")
    print(f"{name}，您好，欢迎来到黑马程序员ATM。请选择操作：")
    print("查询余额\t[输入1]")
    print("存款\t\t[输入2]")
    print("取款\t\t[输入3]")
    print("退出\t\t[输入4]")
    return input("请输入您的选择：")


while True:
    keyboard_input = main()
    if keyboard_input == '1':
        query()
        continue
    elif keyboard_input == '2':
        num = int(input("您想要存多少钱？请输入："))
        saving(num)
        continue
    elif keyboard_input == '3':
        num = int(input("您想要取多少钱？请输入："))
        get_money(num)
        continue
    elif keyboard_input == '4':
        print("程序退出了")
        break
